package com.hk.blog.repository.jpa;

import com.hk.blog.domain.PermissionMenu;
import com.hk.core.data.jpa.repository.LongIdJpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Set;

public interface PermissionMenuRepository extends LongIdJpaRepository<PermissionMenu> {

    void deleteByPermissionId(Long permissionId);

    @Query(value = "SELECT t.menuId FROM PermissionMenu t WHERE t.permissionId = ?1")
    Set<Long> findMenuIdsByPermissionId(Long permissionId);

    @Query(value = "SELECT t.permissionId FROM PermissionMenu t WHERE t.menuId = ?1")
    Set<Long> findPermissionIdsByMenuId(Long menuId);
}
